<%@page import="wt.httpgw.URLFactory"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
	String path = request.getContextPath();
	request.setCharacterEncoding("utf-8");

	URLFactory urlfactory;
	String baseHref = "";
	String url = "";
	urlfactory = new URLFactory();
	baseHref = urlfactory.getBaseHREF();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PAD Show</title>

<link rel="stylesheet" href="../padShow/font/iconfont.css">
<style type="text/css">
body {
	background: #ddecf5;
	margin: 0;
}

#box3 {
	position: relative;
	margin: 12% 37%;
	height: 200px;
	padding-left: 3%;
	padding-top: 0%;
	width: 32%;
	background-color: white;
}

#box2 {
	position: absolute;
	width: 50%;
	margin-left: 100%;
	margin-top: -45%;
	z-index: 9;
}

#font2 {
	font-family: verdana;
	font-size: 45px;
	font-weight: 900;
	color: #cdcdcd;
	padding-left: 2%;
}

#box1 {
	height: auto;
	padding-left: 30px;
	margin-top: 20px;
	min-width: 1200px;
}

#box0 {
	float: inline-start;
	width: 100%;
	background-color: white;
	padding-top: 1px;
	margin-top: 0%;
}

#box3  i {
	font-size: 190px;
	color: #cdcdcd;
	margin: auto auto;
}

table {
	position: absolute;
	border: 1px solid #666;
	margin-left: 10px;
	margin-top: 38px;
	width: 90%;
	border-collapse: collapse;
	background-color: white;
}

td {
	vertical-align: middle;
	text-align: center;
	height: 28px;
}

th {
	border: 1px solid #666;
	font-family: 'Microsoft YaHei';
	font-size: 17px;
	font-weight: 500;
	height: 35px;
	background-color: #eee;
}

ul {
	width: 175px;
	border: 1px solid #B7D5EA;
	position: absolute;
	top: 67px;
	left: 52px;
	box-sizing: border-box;
	padding: 0;
	font-size: 12px;
	list-style: none;
	border-top: 0px;
}

ul li {
	line-height: 24px;
	color: black;
	box-sizing: border-box;
	background-color: white;
	list-style-type: none;
	display: block;
	text-indent: 0.5em;
}

ul li:hover {
	background: #eee;
}

#box4 {
	position: relative;
	display: inline;
}

tr:hover {
	background-color: #eee;
}

.tr1 {
	background-color: #eee;
}

.tr2 {
	background-color: white;
}

#iframItem {
	display: none;
	width: 100%;
	height: 500px;
	margin-left: -20px;
	border: none;
	margin-top: 20px;
	min-width: 1000px;
}

#loadingImg {
	position: fixed;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	display: none;
	z-index: 999999999999;
}

#loadingImg img {
	width: 100px;
	height: 100px;
	position: absolute;
	left: 50%;
	margin-left: -50px;
	top: 100px;
}
</style>


</head>
<script type="text/javascript" src="../../javascript/jQuery1.7.js"></script>
<script type="text/javascript" src="../../javascript/jquery.cookie.js"></script>
<script type="text/javascript" src="../../javascript/history.js"></script>

<script type="text/javascript">   
    self.focus(); 
   </script>

<script type="text/javascript">
    
    	function funChange(){
    		var s1 = document.getElementById("s1");
    		var s2 = document.getElementById("s2");
    		var s3 = document.getElementById("s3");
    		var s4 = document.getElementById("s4");
    		var snumber = document.getElementById("number");
    		var sname = document.getElementById("name");
    		var myselect = document.getElementById("numType");
    		var index=myselect.selectedIndex; 
    		if(index == 1){
    			s3.style.display="";
    			s4.style.display="";
    			s1.style.display="none";
    			s2.style.display="none";
    			snumber.value="";
    		} else{
    			s3.style.display="none";
    			s4.style.display="none";
    			s1.style.display="";
    			s2.style.display="";
    			sname.value="";
    		}
    	}
    
        function check() {
            var number = document.getElementById("number").value;
            if(number=="请输入“料号”或“图号”!"){
            	number="";
            }
            var numType = document.getElementById("numType").value;
            var name = document.getElementById("name").value;
            if(name=="请输入图纸名称！"){
            	name="";
            }
            
            if(number=="" && numType=="" && name==""){
            	alert("请输入搜索内容！");
            } else if(number!="" && numType==""){
            	alert("请选择搜索类型！")
            } else if(numType=="partType" && number==""){
            	alert("请输入料号！");
            } else if(numType=="docType" && number=="" && name==""){
            	alert("请输入图号或名称！")
            } else{
                var obj = document.getElementById("box3");
                if(obj.style.display==""){
               // obj.style.display = "none";
                } else{

                } 
                submit(number,numType,name);
            }
           
        }
       
        $(function(){

            $.ajaxSetup ({
            cache: false //关闭AJAX缓存
            });
            });
        
        
            function submit(number,numType,name){
				    $("#loadingImg").css({
				    display:"block"
				    })
				        $.ajax({
				            scriptCharset: 'utf-8', 
				                    type : "get",
				                    url : "<%=path%>/app/show/showDrawing?numType="
				                        + encodeURI(numType) + "&number=" + encodeURIComponent(number) +"&name=" + encodeURIComponent(name),
				                    data : {},
				                    dataType: 'text', 
				                    //contentType: "application/x-www-form-urlencoded; charset=utf-8",
				                    success : function(msg) {
				                        $("#loadingImg").css({
				                            display:"none"
				                        })
				                        $('#tb tr:gt(0)').remove();//删除之前的数据
				                        
				                        var str = msg;
				                        var dataObj = eval("(" + str + ")");
				                        if(dataObj.status == "failed"){
				                        $("#iframItem").attr("src","");
						                        var arr = dataObj.data;
						                        alert(arr[0].str);
						                        //alert("编号不存在，请重新输入！");
				                        } else if(dataObj.status=="success"){
				                            var arrobj = dataObj.data;
				                            if(arrobj.length==0){
				                            	alert("不存在符合条件的数据！")
				                            	return;
				                            }
				                            var s = '';
				                        for(var i=0;i<arrobj.length;i++){
				                            if(i!=(arrobj.length-1)){
				                                s+=JSON.stringify(arrobj[i])+"&;";
				                            }else{
				                                s+=JSON.stringify(arrobj[i]);
				                            }
				                        }
				        var obj = document.getElementById("box3");
				        if(obj.style.display==""){
				        obj.style.display = "none";
				        } else{
				
				        }
				                localStorage.setItem("PadDataList",s);
				                $("#iframItem").css({
				                    "display":"block"
				                })
				                //alert("origin:"+location.origin);
				                $("#iframItem").attr("src","<%=baseHref%>"+"netmarkets/jsp/ext/BOMECO/tianma/materialPages/padShow.html")
				
				                        }
				                    },
				                    error: function (XMLResponse) {
				                        alert(" 错误信息：" + XMLResponse.responseText);
				                    }
				                })
        }
            
            function setColor(){
              　　var trs=document.getElementById("tb").getElementsByTagName("tr");//获取tbid的table中所有tr的信息
                    for(var i=0;i<trs.length;i++)
                    {
                          　　　　if(i%2==0){
                              trs[i].className="tr1";
                          　　　　}else{
                              trs[i].className="tr2";  
                          　　　　}
                    }
            }
    </script>


<body>
	<div id="loadingImg">
		<img
			src="" />
	</div>
	<div id="box0">
		<div id="box1">
			<span>搜索类型:</span><span> <select id="numType" name="numType"
				onchange="funChange()">
					<!-- <option value="" selected="selected">请选择搜索类型：</option> -->
					<option value="partType" id="partType" selected="selected">料号搜索</option>
					<option value="docType" id="docNum">图纸名称搜索</option>
					<option value="docType" id="docType">图号搜索</option>
			</select>
			</span> <span id="s1" style="margin-left: 10px;">编号:</span> <span id="s2">
				<div id="box4">
					<input type="text" id="number" value="请输入“料号”或“图号”!"
						style="width: 170px;"
						onfocus="javascript:if(this.value=='请输入“料号”或“图号”!')this.value='';"
						onblur="javascript:if(this.value=='')this.value='请输入“料号”或“图号”!';">

					<!-- onfocus="this.value='';" -->
					<div id="box2">
						<ul id="history">
						</ul>
					</div>
				</div>

			</span> <span id="s3" style="margin-left: 10px; display: none;">图纸名称:</span>
			<span id="s4" style="display: none;"> <input type="text"
				id="name" value="请输入图纸名称！" style="width: 170px;"
				onfocus="javascript:if(this.value=='请输入图纸名称！')this.value='';"
				onblur="javascript:if(this.value=='')this.value='请输入图纸名称！';">
			</span>

			<button id="btn1" onclick="toSearch();check()">
				<i class="iconfont">&#xe60b;</i>
			</button>

			<hr color="black" width=95%
				style="position: absolute; margin-top: 2%; margin-left: 0%" />

			<iframe id="iframItem" src=""></iframe>





		</div>

		<div id="box3" style="display:">
			<i class="iconfont">&#xe63b;</i>
			<p>
				<font id="font2">暂无数据</font>
			</p>
		</div>
	</div>
</body>
</html>